Skip to content

fix(C-0312, C-0313): match Substrate WorkerPool at ate.dev/v1 - #217

Merged
matthyx merged 3 commits into
kubescape:mainfrom
harshitnub077:fix/substrate-workerpool-v1
Dec 3, 2026
Merged

matthyx merged 3 commits into
kubescape:mainfrom
harshitnub077:fix/substrate-workerpool-v1

Conversation

@harshitnub077

@harshitnub077 harshitnub077 commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Overview

The VAPs for C-0312 and C-0313 match Substrate's WorkerPool only at ate.dev/v1alpha1. Substrate serves it only at ate.dev/v1 from v1.0.0 on (v0.7.0-alpha1 in the kagent-dev build that kagent 1.0.x installs), so on a current install these policies never see a WorkerPool. This is the cel-admission-library half of kubescape/regolibrary#1011; the regolibrary half is kubescape/regolibrary#1015.

This PR:

  • adds v1 next to v1alpha1 in the ate.dev rule of both policies (one line each), so older Substrate installs stay covered;
  • moves the test CRD's WorkerPool version from v1alpha1 to v1, and the agent-worker-pool.yaml test resource to ate.dev/v1, so the tests run against what Substrate serves today;
  • updates the C-0312 and C-0313 policy docs and agent-runtime-posture.md, which said WorkerPool is ate.dev/v1alpha1 only, and points the WorkerPool field reference at Substrate's v1 types at v1.0.1 (same change as the regolibrary docs in fix(rules): match Substrate WorkerPool at ate.dev/v1 in C-0312, C-0313 and C-0317 regolibrary#1015).

The test CRD serves only v1 on purpose. With both versions served, the API server's default matchPolicy: Equivalent converts a v1 request and applies the v1alpha1-only policy anyway, which hides the bug. Real Substrate serves no v1alpha1, so there's nothing equivalent to match.

How to Test

scripts/run-all-control-tests.sh flow (test CRDs from test-resources/agent-sandbox-test-crds.yaml, then run-control-tests.py per control), on kind with Kubernetes v1.37.0, for C-0312 and C-0313. python3 -m unittest discover -s scripts -p 'test_*.py' and go test ./... in tools/celcli pass too.

Before (main's policies, same v1-only test CRD)

C-0312: 17 passed, 2 failed
  worker-tag:       Test failed: expected to fail but passed
  worker-uppercase: Test failed: expected to fail but passed
C-0313: 62 passed, 4 failed
  worker-evil:  Test failed: expected to fail but passed
  worker-host:  Test failed: expected to fail but passed
  worker-local: Test failed: expected to fail but passed
  worker-port:  Test failed: expected to fail but passed

The insecure WorkerPools are admitted because the policy never applies to v1.

After (this branch)

C-0312: 19 passed, 0 failed  (Control tests passed!)
C-0313: 66 passed, 0 failed  (Control tests passed!)

Related issues/PRs:

@dakshhhhh16 here's the VAP side, as you asked.

Summary by CodeRabbit

  • Policy Updates
    • WorkerPool policies now support both ate.dev/v1 and ate.dev/v1alpha1 for create and update operations. Existing image validation remains unchanged.
  • Documentation
    • Updated policy and runtime posture documentation to reflect support for both WorkerPool API versions and clarify relevant version details.

Substrate serves WorkerPool only at ate.dev/v1 since v0.7.0-alpha1. Keep v1alpha1 for older installs and test against a v1-only CRD like current Substrate.

Signed-off-by: Harshit Kudhial <122823756+harshitnub077@users.noreply.github.com>
Say C-0312 and C-0313 apply to WorkerPool at both versions and point the
WorkerPool field reference at Substrate's v1 types at v1.0.1.

Signed-off-by: Harshit Kudhial <122823756+harshitnub077@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings December 3, 2026 04:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The C-0312 and C-0313 admission rules now match WorkerPool resources using ate.dev/v1 alongside v1alpha1. Test resources use v1, and the documentation describes the updated API version coverage.

Changes: WorkerPool v1 support

Layer / File(s) Summary
Extend policy matching and test resources
controls/C-0312/policy.yaml, controls/C-0313/policy.yaml, test-resources/agent-sandbox-test-crds.yaml, test-resources/agent-worker-pool.yaml
The C-0312 and C-0313 rules add v1 while retaining v1alpha1. The test CRD and manifest switch to ate.dev/v1.
Document WorkerPool API versions
docs/policies-based-on-kubescape-controls/kubescape-c-0312-agent-sandbox-image-digests.md, docs/policies-based-on-kubescape-controls/kubescape-c-0313-agent-sandbox-image-registries.md, docs/validating-admission-policies/agent-runtime-posture.md
The policy pages list both API versions. The runtime posture page adds the applicable Substrate version ranges and updates the WorkerPool schema reference.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

Suggested reviewers: matthyx, dakshhhhh16

Merge Risk: Minimal · up to e7b1f

The C-0312 and C-0313 admission policies now also match WorkerPool resources served at ate.dev/v1, so current Substrate installs are covered while v1alpha1 stays supported. The change is small and easy to revert, and I found no concrete merge-blocking risk.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the two controls (C-0312, C-0313) and the change to match Substrate WorkerPool at ate.dev/v1. The changeset updates both VAP policies to match WorkerPool at ate.dev/v1, along with docs…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the two controls (C-0312, C-0313) and the change to match Substrate WorkerPool at ate.dev/v1. The changeset updates both VAP policies to match WorkerPool at ate.dev/v1, along with docs and test resources. The title covers the main change, though it does not mention the v1alpha1 retention or the test CRD change to v1-only.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e518cdd8-1c5b-489a-b215-266a83763aa6
Commits

Reviewing files that changed from the base of the PR and between 6b4107f and e7b1f38.

Files selected for processing: 1

  • docs/validating-admission-policies/agent-runtime-posture.md
Files skipped from review as they are similar to previous changes: 1

  • docs/validating-admission-policies/agent-runtime-posture.md

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Substrate v0.0.0 called the field spec.ateomImage.

Signed-off-by: Harshit Kudhial <122823756+harshitnub077@users.noreply.github.com>

@matthyx matthyx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed head e7b1f38 against main.

Verdict: approve.

  • Need: Substrate serves WorkerPool only at ate.dev/v1 from v1.0.0, so the v1alpha1-only rule in C-0312/C-0313 never sees current installs. Real bug, tracked in regolibrary#1011 (companion regolibrary#1015).
  • Fix: adds v1 next to v1alpha1 in both policies, so older installs stay covered. The CEL expressions are version-agnostic. The test CRD now serves only v1, which keeps the matchPolicy: Equivalent conversion from hiding the bug.
  • Before/After proof: present in the description, with failing-then-passing control tests (C-0312 17/2 → 19/0, C-0313 62/4 → 66/0).
  • CI: I approved the action_required run after checking the PR touches no workflows or scripts. main-policy-automation run 47036854810 completed successfully (test-policy-expressions and test-all-policies). CodeRabbit, DCO and FOSSA also pass.
  • Duplicates: no overlapping PRs. #128 and #103 are the earlier merged WorkerPool work. The author has only this one open PR.
  • Not done: I did not run the tests locally. The assessment rests on static review plus the green CI run.
  • Blockers: none. No nonblocking gaps, so no follow-up issue.

@matthyx
matthyx merged commit 371e2b7 into kubescape:main Dec 3, 2026
7 checks passed
@matthyx matthyx moved this to To Archive in KS PRs tracking Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To Archive

Development

Successfully merging this pull request may close these issues.

3 participants